<?php
$date_att = array(
			'name'		=> 'datepicker',
            'id'        => 'datepicker',
            'value'     => 'Click to select date.',
            );
			
?>

<div style="float: left;">
	<div class="ui-corner-top side_menu" style="width: 700px;">Attendance</div>
	<div style="border:1px  solid #286bcc;">
		<?if(isset($system_message))echo $system_message;?>
		<? echo form_open('teacher/goto_attendance/' . $room_id)?>
			<div class="input-block">
				<?
					echo form_label('Date','Date');
					echo form_input($date_att);
					echo form_submit('submit_date', 'Go to Date');
				?>
			</div>
		<? echo form_close() ?>
		
		
		<fieldset>
			<legend>Class Attendance</legend>
			<?if($now_att !== FALSE):?>
				<?=form_open('teacher/save_attendance/' . $room_id)?>
				<table class="data-table">
					<thead class="tabular-head">
						<tr>
							<th></th>
							<th>Student</th>
							<th>Date</th>
							<th></th>
							<th></th>
						</tr>
						<tr>
							<th>ID</th>
							<th>Name</th>
							<th><?=date('F d, Y', strtotime($date_now))?></th>
							<th>Reason</th>
							<th>Remarks</th>
						</tr>
					</thead>
					<tbody class="tabular">
						<?foreach($now_att as $att):?>
							<?$id = $att->profile_id; ?>
							<tr>
								<td><?=$id; ?></td>
								<td><?=strtoupper($att->lastname) . ', ' . $att->firstname . ' ' . $att->middlename; ?></td>
								
								<td><?$att_value = set_value('attendance[' . $id . '][in_class][]') == FALSE ? $att->in_class : set_value('attendance[' . $id . '][in_class][]');
									$att_options = array(''=>'', '1' => 'Present', '0'=>'Absent', '2'=>'Tardy', '3'=>'Cut Class');
									echo form_dropdown('attendance[' . $id . '][in_class][]', $att_options, $att_value);?>
								</td>
								<td><input type="text" name="attendance[<?=$id?>][reason][]" id="reason" value="<?=$att->reason?>" <?if($att->in_class == 1) echo "disabled"?>/></td>
								<td><input type="text" name="attendance[<?=$id?>][remarks][]" id="remarks" value="<?=$att->remarks?>" /></td>
							</tr>
						<?endforeach;?>
					</tbody>
				</table>
				<?=form_hidden('section_id', $section_id); ?>
				<?=form_submit('submit_attendance', 'Save Attendance'); ?>
				<?=form_close()?>
			<?else:?>
				<table class="data-table">
					<thead class="tabular-head">
						<tr>
							<th>Error. Go to <a href="<?= site_url('teacher/attendance') . '/' . $room_id;?>">today's attendance</a> or 
								<a href="<?= site_url('teacher/new_attendance') . '/' . $room_id . '/' . $selected_date; ?>">create</a> for the date, <?if (isset($selected_date)) echo date('F d, Y', strtotime($selected_date))?>
							</th>
						</tr>
					</thead>
				</table>
			<?endif;?>
		</fieldset>
		<div class="clearfloat"></div>
	</div>
	<div>&nbsp;</div>
</div>